/**
 * 
 */
package com.zhiteng.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiteng.entity.PointLimit;
import com.zhiteng.mapper.PointLimitMapper;
import com.zhiteng.service.PointLimitService;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

/**  
* <p>Title: PointLimitServiceImpl.java</p>  
* <p>Description:积分限制Service </p>  
* @author dragon  
* @date 2019年1月4日  
* @version 1.0  
*/
@Service
public class PointLimitServiceImpl implements PointLimitService {
	@Autowired
	private PointLimitMapper pointLimitMapper;

	@Override
	public PointLimit queryPointLimitByTeacherIdAndType(String teacherId, Integer type) {
		PointLimit pointLimit = new PointLimit();
		pointLimit.setTeacherId(teacherId);
		pointLimit.setType(type);
		return pointLimitMapper.selectOne(pointLimit);
	}

	@Override
	public void savePointLimit(PointLimit pointLimit) {
		pointLimitMapper.insert(pointLimit);
	}

	@Override
	public void updatePointLimit(PointLimit pointLimit) {
		pointLimitMapper.updateByPrimaryKey(pointLimit);
	}

	@Override
	public int updatePointLimitByTypeList(List<Integer> typeList) {
		PointLimit pointLimit = new PointLimit();
		pointLimit.setCurrCyclePoint(0); //	积分重置
		
		Example example = new Example(PointLimit.class);
		Criteria criteria = example.createCriteria();
		criteria.andIn("type", typeList);
		
		return pointLimitMapper.updateByExampleSelective(pointLimit, example);
	}
	
}
